package com.liuguangaop.advice;

import com.liuguangaop.exception.MyException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.InitBinder;

import java.beans.PropertyEditorSupport;
import java.util.Date;

/**
 * @ClassName: TestControllerAdvice
 * @Description：
 * @Author: wanghr
 * Date: 3:54 PM 2020/7/9
 * Version: 1.0
 */
@Slf4j
@ControllerAdvice
public class TestControllerAdvice {

//    @InitBinder
//    public void initBinder(WebDataBinder webDataBinder) {
//        webDataBinder.registerCustomEditor(Date.class,new PropertyEditorSupport());
//    }

    @ExceptionHandler(MyException.class)
    public void handleMyException(MyException myexp) {
        log.info("我的异常描述：{}",myexp.getMessage());
    }
}
